<?php
/**
 * Created by jinqiang on 2024/6/4 15:38.
 * Copyright (c) 2024, Your Company. All rights reserved.
 */


namespace App\Http\Services\Banshi;


use App\Http\Models\Mysql\SsySizeRuleTable;

class SizeService
{
    public function search($param)
    {
        $conn = (new SsySizeRuleTable());
        if($param['type'] ?? ""){
            $conn = $conn->where('type', $param['type']);
        }
        if($param['title'] ?? ""){
            $conn = $conn->where('s_title', 'like', "%".$param['title']."%");
        }
        if($param['status'] != ""){
            $conn = $conn->where('status', (Int)$param['status']);
        }
        $res = $conn->orderBy("createtime", "desc")->paginate((Int)$param['limit'])->toArray();
        return ['data' => $res['data'], 'total' => $res['total']];
    }

    public function save($id, $data)
    {
        return (new SsySizeRuleTable())->updateData($id, $data);
    }

    public function create($data)
    {
        return (new SsySizeRuleTable())->createData($data);
    }
}
